/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package automate;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;

/**
 *
 * @author lucas
 */
class ReduireVitesseListener implements ActionListener {
    Diapositives diapo;
    public ReduireVitesseListener(Diapositives diapo) {
        this.diapo = diapo;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        //a voir pour ne pas changer de diapo quand on ralentit
        Timer t = diapo.getTimer();
        switch(diapo.getEtat()){
            case 2: //on change de sens - 3s arriere
                diapo.setEtat(5);
                break;
            case 3: // on repasse a 3s avant
                t.stop();
                t.setDelay(3000);
                diapo.setEtat(2);
                t.start();
                break;
            case 4: //on repasse a 2s avant
                t.stop();
                t.setDelay(2000);
                diapo.setEtat(3);
                diapo.activerBoutonAvancer();
                t.start();
                break;
            case 5: //on passe à 2s en marche arrière
                t.stop();
                t.setDelay(2000);
                diapo.setEtat(6);
                t.start();
                break;
            case 6: //on passe à 1s en marche arrière
                t.stop();
                t.setDelay(1000);
                diapo.setEtat(7);
                diapo.desactiverBoutonReculer();
                t.start();
                break;
        }
    }
    
}
